<template>
  <div style="position: relative;">
    <div class="card-content">
      <div class="top-content">
        <van-image width="1.15rem" height="1.4rem" fit="cover"
          src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" class="image-container"/>
        <div class="progress-text">
          <span>Lv:{{ props.level }}</span>
          <span>Task:{{ props.task }}</span>
        </div>
        <div class="progress-bar">
          <div class="bot" v-for="(item,index) in props.task" :key="index"
          :class="{ bot_active: index < props.level }"></div>
        </div>
      </div>
      <div class="bottom-content">
        <div class="text-content">
          <div class="des">Yellow God of Wealth: #123948</div>
          <div class="num">123.00 <span class="unit">USDY</span></div>
        </div>
        <ClickableBox>
          <div class="buy-btn" @click="buy">BUY</div>
        </ClickableBox>
      </div>
    </div>
    <div class="card-num">
      #23433
    </div>
  </div>

</template>

<script setup lang="ts">
import ClickableBox from '../../../components/ClickableBox.vue';
interface Props {  
  level: number;
  task: number;
} 
const props = defineProps<Props>();  
const emit = defineEmits();
const buy = () => {
  emit('buy')
}


</script>

<style scoped lang="less">
.card-content {
  margin: 13px 0rem;
  width: 1.6rem;
  height: 2.3rem;
  border: 3px solid #4407A6;
  background-color: #E0C7F5;
  border-radius: 0.1rem;
  overflow: hidden;

  .top-content {
    // background-color:#E0C7F5;
    height: 83%;
    display: flex;
    flex-direction: column;
    align-items: center;
    .image-container{
      border: 3px solid #4407A6;
      border-radius: 0.1rem;
      margin-top: 0.15rem;
      overflow: hidden;
    }
    .progress-text {
      display: flex;
      justify-content: space-between;
      width: 75%;
      font-size: 0.1rem;
      margin: 0.02rem 0rem;
    }
    .progress-bar{
      display: flex;
      width: 75%;
      .bot{
        flex:1;
        height: 0.03rem;
        margin: 0rem 0.01rem;
        background-color: #D9D9D9;
        border-radius: 0.1rem;
      }
      .bot_active{
        background-color: #87F9B1;
      }
      
    }
  }

  .bottom-content {
    height: 17%;
    background-color: #B58AD8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .text-content{
      margin-left: 0.03rem;
      display: flex;
      flex-direction: column;
      align-items: baseline;
      justify-content: center;
      .des{
        font-size: 0.07rem;
      }
      .num{
        font-weight: 700;
        font-size: 0.12rem;
        .unit{
          font-size: 0.1rem;
          font-weight: 500;
        }
      }
    }
    .buy-btn{
      width: 0.5rem;
      height: 0.2rem;
      background-color: aqua;
      border-radius: 0.3rem;
      border: 2px solid #000;
      margin-right: 0.03rem;
    }
  }
}

.card-num {
  position: absolute;
  border: 3px solid #4407A6;
  background-color: #E0C7F5;
  border-radius: 0.5rem;
  width: 0.8rem;
  height: 0.2rem;
  top: 0px;
  left: 50%;
  transform: translateX(-50%);
  line-height: 0.2rem;
}
</style>